-
Notifications
You must be signed in to change notification settings - Fork 39
[MOB-12231] Put all calls to the native layer in a class called IterableApi #737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MOB-12231] Put all calls to the native layer in a class called IterableApi #737
Conversation
Diff Coverage: The code coverage on the diff in this pull request is 86.9%. Total Coverage: This PR will increase coverage by 1.6%. File Coverage Changes
🛟 Help
This is from Qlty Cloud, the successor to Code Climate Quality. Learn more. |
All good ✅ |
…lure' into jwt/MOB-12231-create-an-iterableapi-class-for-api-calls
…lure' into jwt/MOB-12231-create-an-iterableapi-class-for-api-calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Centralizes all direct native layer interactions into a new IterableApi class and refactors existing classes (Iterable, IterableInAppManager, IterableInboxDataModel, IterableAuthManager) to use it. Adds comprehensive unit tests for IterableApi and updates exports.
- Introduces IterableApi wrapper consolidating native bridge calls
- Refactors existing classes to delegate to IterableApi (removing duplicated native calls and most logging)
- Adds extensive test coverage for IterableApi methods
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/inbox/classes/IterableInboxDataModel.ts | Refactors inbox data model methods to use IterableApi instead of RNIterableAPI. |
src/inApp/classes/IterableInAppManager.ts | Refactors in-app manager to delegate to IterableApi and adds usage example. |
src/core/classes/index.ts | Re-exports IterableApi and IterableAuthManager. |
src/core/classes/IterableAuthManager.ts | Switches to IterableApi for auth-related native calls. |
src/core/classes/IterableApi.ts | New centralized wrapper encapsulating all native layer interactions. |
src/core/classes/IterableApi.test.ts | Adds comprehensive tests for all IterableApi methods. |
src/core/classes/Iterable.ts | Refactors to route native operations through IterableApi and simplifies in-app manager instantiation. |
src/mocks/MockRNIterableAPI.ts | Adapts mock to support new usage patterns (jest.fn wrappers, added methods). |
Comments suppressed due to low confidence (1)
src/core/classes/Iterable.ts:352
- IterableApi.getAttributionInfo already returns an IterableAttributionInfo | undefined; this extra then block redundantly re-wraps the object. Simplify by returning IterableApi.getAttributionInfo() directly to reduce duplication.
return IterableApi.getAttributionInfo().then(
(
dict: {
campaignId: number;
templateId: number;
messageId: string;
} | null
) => {
if (dict) {
return new IterableAttributionInfo(
dict.campaignId as number,
dict.templateId as number,
dict.messageId as string
);
} else {
return undefined;
}
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
The only functionality to check is actually The rest is just testing an a name change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* @param id - The unique identifier of the message to be marked as read. | ||
*/ | ||
setMessageAsRead(id: string) { | ||
Iterable?.logger?.log('IterableInboxDataModel.setMessageAsRead'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not want Logging? Native layer had some extra debug logs to understand internal working of SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do, but these logs are now done whenever any function in IterableApi is called. They're still there, they just moved locations.
); | ||
|
||
return RNIterableAPI.getHtmlInAppContentForMessage(id).then( | ||
return IterableApi.getHtmlInAppContentForMessage(id).then( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acknowledging RN prefix is getting removed and its more on-par with native SDKs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... that's good to know!
@@ -1,4 +1,4 @@ | |||
import { RNIterableAPI } from '../../api'; | |||
import { IterableApi } from '../../core/classes/IterableApi'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to see RNIterable is now Iterable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im assuming this replaces the RNIterableApi class. However, I dont see the removal of that file. If it exists, what is it supposed to have?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's loaded from the native layer, so it doesn't actually replace it
Co-authored-by: Copilot <[email protected]>
🔹 JIRA Ticket(s) if any
✏️ Description
Extract native layer functions so that they are all listed in one place
Testing
There is no functionality change, so you can just make sure the app builds and logs in on either android or ios